
package stratego.java.ssm.piece;

import java.awt.Color;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class BombPiece extends Piece
{
	private BufferedImage	       front;
	private BufferedImage	       back;
	protected static BufferedImage	orig;
	
	public BombPiece(Color[] gradient)
	{
		super(0);
		BufferedImage image = null;
		try
		{
			// A cross platform way to get to the desired image. Unix uses \, whereas Windows
			// uses /
			File folder = new File("img");
			File file = new File(folder, "bomb.png");
			image = ImageIO.read(file);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		if (orig == null)
			orig = image;
		front = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
		PieceUtilities.drawChipAndIcon(front, image, gradient[0], gradient[1], gradient[2]);
		back = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
		PieceUtilities.drawChipBack(back, gradient[0], gradient[1], gradient[2]);
		front.getGraphics().dispose();
		back.getGraphics().dispose();
	}
	
	@Override
	public boolean isBomb()
	{
		return true;
	}
	
	@Override
	public boolean isFlag()
	{
		return false;
	}
	
	@Override
	public boolean isSpy()
	{
		return false;
	}
	
	@Override
	public boolean isScout()
	{
		return false;
	}
	
	@Override
	public boolean isMiner()
	{
		return false;
	}
	
	@Override
	public boolean isEmpty()
	{
		return false;
	}
	
	@Override
	public boolean isBlock()
	{
		return false;
	}
	
	@Override
	public Image getImage()
	{
		return front;
	}
	
	@Override
	public Image getOriginalImage()
	{
		return orig;
	}
	
	@Override
	public String toString()
	{
		return "Bomb";
	}
	
	@Override
	public Image getBack()
	{
		return back;
	}
}
